package xquery;

import java.util.ArrayList;

import org.w3c.dom.Node;

public class XQueryComposedExp extends XQuery {
	XQExpression[] xquery;

	@Override
	public XPathData eval(XQContext context, ArrayList<Node> currentNodeList) {
		XPathData result = xquery[0].eval(context, currentNodeList);
		XPathData intermediate = null;
		for(int i=1;i<xquery.length;i++) {
			intermediate = xquery[i].eval(context, currentNodeList);
			result.getList().addAll(intermediate.getList());
		}
		return result;
	}
	public String toString()
	{
		StringBuffer sb = new StringBuffer("");
		for(int i = 0;i<xquery.length-1;i++)
		{
			sb.append(xquery[i] + ", ");
		}
		sb.append(xquery[xquery.length-1]);
		return sb.toString();
		
	}
}
